package com.rw.test.config.exception;

import com.rw.engine.permission.exception.PermissionException;
import com.rw.test.vo.ResultVO;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class PermissionExceptionHandler {
    @ResponseBody
    @ExceptionHandler(PermissionException.class)
    public ResultVO<String> permissionExceptionHandler(PermissionException exception) {
        return new ResultVO<>(1, "很抱歉，您没有权限访问该接口。需要的权限：" + exception.getPermission());
    }
}
